package Storage_Hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import java.io.IOException;

public class FinancialDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        args = new String[]{"D:/niit/input/demo", "demo"};

        Configuration conf = HBaseConfiguration.create();
        conf.set("hbase.zookeeper.quorum","node-1,node-2,node-3");
        Job job = Job.getInstance(conf);

        job.setJarByClass(FinancialDriver.class);

        job.setMapperClass(FinancialMapper.class);
        job.setMapOutputKeyClass(ImmutableBytesWritable.class);
        job.setMapOutputValueClass(Put.class);

        TableMapReduceUtil.initTableReducerJob(args[1], FinancialReducer.class, job);

        FileInputFormat.setInputPaths(job, args[0]);

        System.exit(job.waitForCompletion(true)? 0 : 1);


    }
}
